package com.hqyj.module.InformationQuery.controller;


import com.github.pagehelper.PageInfo;
import com.hqyj.module.InformationQuery.entity.UserInfo;
import com.hqyj.module.InformationQuery.service.UserInformationService;
import com.hqyj.module.clock.pojo.SearchBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.HashMap;

/**
 * @Description：UserInfoController
 * @Author ：Cwd
 * @Date ：2021/10/8 10:13
 */
@RestController
@RequestMapping("/user-information")
public class UserInformationController {

    @Autowired
    private UserInformationService userInformationService;

    /**
     *  http://127.0.0.1:8086/user-information/user/admin1
     */
    @GetMapping("/user/{userName}")
    public HashMap<String, Object> getUserInfoByUserId(@PathVariable String userName){
        HashMap<String, Object> map = userInformationService.getUserInfoByUserName(userName);
        return map;
    }

    /**
     * http://127.0.0.1:8086/user-information/users --- 分页查询
     * {"currentPage":1,"pageSize":5,"orderBy":"user_id","direction":"desc","keyword":""}
     * @param searchBean
     * @return
     */
    @PostMapping(value = "/users",consumes = "application/json")
    public PageInfo<UserInfo> getUsersBySearchBean(SearchBean searchBean) {
        return userInformationService.getUsersBySearchBean(searchBean);
    }
}
